package com.zhj.springbootinit.bizmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * 测试用到的交换机和消息队列（只用执行一次）
 */

public class BiMqInit {
    public static void main(String[] args) {


        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("localhost");
        try {
            Connection connection = connectionFactory.newConnection();
            Channel channel = connection.createChannel();
            channel.exchangeDeclare(BIMQConstant.BI_MQ_EXCHANGE, "direct");
            String queue_name = BIMQConstant.BI_MQ_QUEUE;
            channel.queueDeclare(queue_name, true, false, false, null);

            channel.queueBind(queue_name, BIMQConstant.BI_MQ_EXCHANGE, BIMQConstant.BI_ROUTING_KEY);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
